<script setup>
import { ref } from 'vue'
import wxsrr from '@/assets/wxsrr.png'
import qqsrr from '@/assets/qqsrr.png'
import phonesrr from '@/assets/phonesrr.png'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user.js'
const user = useUserStore()
const router = useRouter()
const showBottom = ref(true)
const show = ref(false)
const flag = ref(false)

function loginFn() {
    user.changeLogin('true')
    router.push('/home')
}
function loginClick() {
    if (flag.value) {
        loginFn()
    } else {
        show.value = true
    }
}
</script>

<template>
    <div>
        <van-popup v-model:show="showBottom" position="bottom" close-on-click-overlay>
            <template #default>
                <div class="content-div">
                    <div @click="$router.back()" class="XClass">X</div>
                    <h3 style="font-size: 0.18rem; margin-top: 5px;">登录发现更多精彩</h3>
                    <span style="font-size: 0.22rem; margin-top: 10px;">166****6666</span>
                    <span style="font-size: 0.12rem;color: #ccc;">中国电信提供认证服务</span>
                    <van-button @click="loginClick">本机号码一键登录</van-button>
                    <p>
                        <img class="imgClass" :src="wxsrr" alt="">
                        <img class="imgClass" :src="qqsrr" alt="">
                        <img class="imgClass" :src="phonesrr" alt="">
                    </p>
                    <footer>
                        <input type="checkbox" style="margin-top: 2px;" v-model="flag">
                        <span>
                            使用手机号登录并同意，
                            <span style="color: #f66;margin-left: -0.12rem;">
                                《中国电信认证服务条款》
                            </span>
                            、
                            <span style="color: #f66;margin-left:-0.12rem;">
                                《用户协议》
                            </span>
                            和
                            <span style="color: #f66;">
                                《隐私政策》
                            </span>
                        </span>
                    </footer>
                </div>
            </template>
        </van-popup>
        <van-dialog v-model:show="show" :showConfirmButton="false">
            <div class="dialogsrr">
                <div class="cancel" @click="show = false">X</div>
                <span class="span1">
                    请先仔细阅读并同意 <span>《中国电信认证服务条款》</span>、<span>《用户协议》</span>和 <span>《隐私政策》</span>
                </span>
                <van-button @click="loginFn">同意协议并登录</van-button>
            </div>
        </van-dialog>

    </div>
</template>

<style lang="scss" scoped>
.content-div {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 3rem;
    background-color: #fff;
    font-size: 0.16rem;
    position: relative;

    .XClass {
        position: absolute;
        top: 0.1rem;
        left: 0.1rem;
        font-size: 0.16rem;
    }

    .imgClass {
        width: 0.3rem;
        height: 0.3rem;
        margin: 0.05rem;
    }

    .van-button {
        width: 2.8rem;
        height: 0.4rem;
        margin-top: 20px;
        background-color: #f66;
        border-radius: 0.2rem;
        color: #fff;
        margin-bottom: 30px;
    }

    footer {
        width: 2.2rem;
        display: flex;
        justify-content: center;
        align-items: start;
        font-size: 0.12rem;
        color: #999;
    }



}

.dialogsrr {
    position: relative;

    .span1 {
        font-size: 0.14rem;
        margin-top: 0.2rem;
        text-align: center;

        span {
            color: rgb(209, 42, 42);
        }
    }

    padding: 0.1rem 0.2rem;
    display: flex;
    align-items: center;
    flex-direction: column;

    .van-button {
        width: 2rem;
        height: 0.4rem;
        margin-top: 20px;
        background-color: #f66;
        border-radius: 0.2rem;
        color: #fff;
        margin-bottom: 30px;
    }

    .cancel {
        position: absolute;
        top: 0.1rem;
        right: 0.1rem;
        font-size: 0.12rem;
        color: #999;
    }
}
</style>